package com.ycy.dubbo.impl;

import com.ycy.dubbo.client.ExpService;
import com.ycy.dubbo.exp.MyException;
import com.ycy.dubbo.exp.ProviderException;
import org.apache.dubbo.config.annotation.DubboService;

@DubboService(version = "1.1.0")
public class ExpServiceImpl implements ExpService {

  @Override
  public int throwExp(String expType) {
    try {
      int a = 1 / 0;
    } catch (Exception e) {
      if ("a".equals(expType)) {
        //1 使用 java 的自带的 ArithmeticException
        throw e;
      } else if ("b".equals(expType)) {
        //2 自定义异常
        throw new MyException("自定义异常");
      }
      throw new ProviderException("provider 独有的异常");

    }
    return 0;
  }

}
